<?php 
session_start();
include('inc.db.php');

if(isset($_POST['bestel'])){
	if(isset($_POST['productA'])){
		$_SESSION['aantalA'] = $_POST['aantalA']; 
	}else{
		$_SESSION['aantalA'] = '0';
	}
	
	if(isset($_POST['productB'])){ 
		$_SESSION['aantalB'] = $_POST['aantalB']; 
	}else{
		$_SESSION['aantalB'] = '0';
	}
	
	if(isset($_POST['productC'])){ 
		$_SESSION['aantalC'] = $_POST['aantalC']; 
	}else{
		$_SESSION['aantalC'] = '0';
	}
	
	if(isset($_POST['productD'])){ 
		$_SESSION['aantalD'] = $_POST['aantalD']; 
	}else{
		$_SESSION['aantalD'] = '0';
	}
	
	if(isset($_POST['productE'])){ 
		$_SESSION['aantalE'] = $_POST['aantalE']; 
	}else{
		$_SESSION['aantalE'] = '0';
	}
	
	header('location: bestelling.php');
}

if(isset($_POST['herstel'])){
	header('location: aanpassen.php');	
}

function deleteBestelling($Delete){
		
	if(!mysql_query("DELETE FROM bestellingen WHERE id=".$Delete."")){
		mysql_error();}
		else{
		return "ok";	
		}
	
}

if(isset($_POST['delete'])){
	
		$Delete = $_POST['id'];
		deleteBestelling($Delete);
		$status = deleteBestelling($Delete);
		if($status == 'ok'){
			echo '<h1 style=color:#0f0> Bestelling verwijderd</h1>';
		}else{
			echo '<h1 style=color:#f00>NIET GELUKT</h1>';	
		}
}




?>


<style type='text/css'>
input[name*=aantal] {
	width: 20px;
	line-height: 1.1em;
}
</style>
<form action='form.php' method='post'>
<b>Bestelformulier</b>
<p>
Selecteer de gewenste producten en aantallen in.
</p>
<p>
     product A <label> (2 euro) </label><input type='checkbox' name='productA' /><label> aantal </label><input type='text' value='0' name='aantalA' />
<br/>product B <label> (5 euro) </label><input type='checkbox' name='productB' /><label> aantal </label><input type='text' value='0' name='aantalB' />
<br/>product C <label> (6 euro) </label><input type='checkbox' name='productC' /><label> aantal </label><input type='text' value='0' name='aantalC' />
<br/>product D <label> (7 euro) </label><input type='checkbox' name='productD' /><label> aantal </label><input type='text' value='0' name='aantalD' />
<br/>product E <label> (4 euro) </label><input type='checkbox' name='productE' /><label> aantal </label><input type='text' value='0' name='aantalE' />
<br/><input type='submit' name='bestel' value='bestel' />
<input type='submit' name='herstel' value='bestelling aanpassen'/><br/><br/>
<label>Bestelnummer</label><input type='text' name='id' />
<input type='submit' name='delete' value='bestelling verwijderen'/>
</form>
</p>